
function gt(str){
    return document.querySelector(str);
}
function gts(str){
    return document.querySelectorAll(str);
}

const mouseTab = gt('.nav-menu .productTab');
const product_box = gt('.product-box'); 
mouseTab.onmouseenter = ()=>product_box.style.height = '10.786rem';
mouseTab.onmouseleave = ()=>product_box.style.height = '';


const productitems = gts('.product-container .product-item')
productitems[0].onclick = ()=>location = location.origin + '/views/product/qht.html';
productitems[1].onclick = ()=>location = location.origin + '/views/product/ipsystem.html';
productitems[2].onclick = ()=>location = location.origin + '/views/product/mbmh.html';


const registerButton = gt('.register-button');
registerButton.onclick = ()=>location = 'http://127.0.0.1:5500/pages/register.html'
// const registerDialog = gt('.register-dialog');
// const registerBox1 = gt('.register-dialog .register-box1');
// const registerBox2 = gt('.register-dialog .register-box2');
// const registerForm = gt('.register-dialog form');   // 注册表单
// const closeButton = gts('.register-dialog .close-btn');   // 关闭按钮
// const submitBtn = gt('.register-dialog .submit');   // 提交按钮
// const inputs = gts('.register-dialog input');
// const textArea = gt('.register-dialog textarea');
// const setTimeEl = gt('.register-dialog .know-btn span');
// const iKnow = gt('.register-dialog .know-btn');
// registerButton.onclick = ()=> registerDialog.style.display = 'block';

// 注册数据
// let registerData = {
//     companyName:'',
//     phoneNumber:'',
//     linkman:'',
//     companyAdress:'',
//     leaveMessage:''
// }
// var oInterval;  // 定时器
// inputs[0].oninput = function(){registerData.companyName = this.value;}
// inputs[1].oninput = function(){registerData.phoneNumber = this.value;}
// inputs[2].oninput = function(){registerData.linkman = this.value;}
// inputs[3].oninput = function(){registerData.companyAdress = this.value;}
// textArea.oninput = function(){registerData.leaveMessage = this.value;}
// 校验
// function verify(obj){
//     if(!obj.companyName) return Promise.reject('请输入企业名称');
//     if(!/^1[3456789]\d{9}$/.test(obj.phoneNumber)) return Promise.reject('请输入正确的电话号码');
//     return Promise.resolve();
// };
// http://jxc-test.cloudvast.com/api/create/intentionmember?companyname=??&mobilephone=135152565654&name=1111&address=??&remark=
// function submitRequset(params){
//     // const BaseUrl = 'http://jxc-test.cloudvast.com/api/create/intentionmember?';
//     const BaseUrl = 'http://192.168.3.218:8866/api/basic/create/intentionmember';
//     // const companyname = '&companyname='+params.companyName;
//     // const mobilephone = '&mobilephone='+params.phoneNumber;
//     // const name = '&name='+params.linkman;
//     // const address = '&address='+params.companyAdress;
//     // const remark = '&remark='+params.leaveMessage;
//     // const url = BaseUrl+companyname+mobilephone+name+address+remark;
//     return window.fetch(BaseUrl,{
//         method:'POST',
//         body:{
//             companyname:params.companyName,
//             mobilephone:params.phoneNumber,
//             name:params.linkman,
//             address:params.companyAdress,
//             remark:params.leaveMessage,
//         }
//     })
// }
// 提交
// submitBtn.onclick = (e)=>{
//     e.preventDefault();
//     // console.log(registerData);
//     console.log('触发');
//     submitRequset(registerData).then(res=>{
//         console.log(res)
//     })
//     // registerBox1.style.display = 'none';
//     // registerBox2.style.display = 'flex';
//     // interval()

// }
// 倒计时
// function interval(){
//     oInterval = setInterval(() => {
//         if(+setTimeEl.innerText <= 1){
//             clearInterval(oInterval);
//             resetRegisterPage()
//             setTimeEl.innerText = 4;
//         }
//         setTimeEl.innerText = setTimeEl.innerText-1;
//     }, 1000);
// }
// 重置注册界面
// function resetRegisterPage(bl){
//     clearInterval(oInterval);
//     registerDialog.style.display = 'none';
//     registerBox1.style.display = 'flex';
//     registerBox2.style.display = 'none';
//     if(bl){
//         setTimeEl.innerText = 3;
//     }
//     registerData = {
//         companyName:'',
//         phoneNumber:'',
//         linkman:'',
//         companyAdress:'',
//         leaveMessage:''
//     }
// }
// iKnow.onclick =()=>resetRegisterPage(true);
// closeButton.forEach(i=>i.onclick=()=>resetRegisterPage(true));